package com.zuorenke.help;

import org.springframework.util.CollectionUtils;

import java.util.*;

/**
 * @author Z.R.K
 * @description
 * @create 2019-04-12 09:13:53
 **/
public class MyCollectionUtils extends CollectionUtils {
	public static boolean isEmpty(Object[] t) {
		if (t == null || t.length == 0) {
			return true;
		}else{
			return false;
		}
	}
	
	/**
	 * 向List<List<E>>数据结构的list中新增元素
	 * @param list
	 * @param e
	 */
	public static <E> void addListEle(List<List<E>> list, int index, E e) {
		List<E> itemList = list.get(index);
		if (itemList == null) {
			itemList = new ArrayList<>();
			list.set(index, itemList);
		}
		itemList.add(e);
	}
	

	/**
	 * 截取部分list
	 * @param list
	 * @param offset
	 * @param size
	 * @return
	 */
	public static <T> List<T> subList(List<T> list, int offset, int size) {
		List<T> result = new ArrayList<>();
		for (int i = offset; i < size; i++) {
			result.add(list.get(i));
		}
		return result;
	}
	
	public static <E> List<E> emptyList(){
		return Collections.emptyList();
	}
	
	public static <E> Set<E> emptySet(){
		return Collections.emptySet();
	}
	
	public static <K, V> Map<K, V> emptyMap(){
		return Collections.emptyMap();
	}
}
